<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>排队等候</title>
    <link href="./common/cube.ui.css" rel="stylesheet" />
    <script src="./common/rem.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        html, body {
            width: 100%;
            min-height: 100%;
            background-color: #f5f5f5;
            box-sizing: border-box;
            font-size: 0;
            overflow-x: hidden;
        }
        .wrapper {
            width: 100%;
            box-sizing: border-box;
            padding-top: 1rem;
        }
        .wrapper .header {
            width: 100%;
            height: 1rem;
            background-color: rgba(42, 192, 206, 1);
            position: fixed;
            top: 0;
            left: 0;
            color: #fff;
            font-size: .3rem;
            font-weight: bold;
            display: flex;
            justify-content: center;
            align-items: center;
            text-align: center;
        }
        .wrapper .header .name {
            width: 25%;
        }
        .wrapper .header .No {
            width: 25%;
        }
        .wrapper .none {
            font-size: .28rem;
            color: #999;
            text-align: center;
            line-height: 2rem;
        }
        .wrapper .refresh {
            width: .8rem;
            height: .8rem;
            color: #fff;
            border-radius: 50%;
            font-size: .28rem;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: rgba(42, 192, 206, 1);
            position: fixed;
            right: .2rem;
            bottom: 1rem;
            box-shadow: 0 0 10px rgba(0,0,0,.2);
        }
        .wrapper .content {
            width: 100%;
            background-color: #fff;
        }
        .wrapper .content .row {
            width: 100%;
            min-height: 1rem;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .wrapper .content .row div {
            width: 25%;
            font-size: .28rem;
            color: #999;
            text-align: center;
        }
        .wrapper .content .row div span {
            line-height: .4rem;
        }
        .yellow {
            color: #E6A23C !important;
        }
        .green {
            color: #67C23A !important;
        }
    </style>
    <script src="./common/vue.min.js"></script>
	<script src="./common/axios.min.js"></script>
</head>
<body>
    <div class="wrapper">
        <div class="header">
            <div class="name">项目名</div>
            <div class="No">我的号码</div>
            <div class="No">当前位置</div>
            <div class="No">状态</div>
        </div>
        <div class="none" v-if="list.length == 0">
            暂无排队
        </div>
        <div class="refresh" @click="handleRefresh">刷新</div>
        <div class="content" v-if="show">
            <div class="row" v-for="(item, index) in list" :key="index">
                <div>
                    <span>{{ item.queueName }}</span>
                </div>
                <div>{{ item.seq }}</div>
                <div style="color: #000;">{{ item.queueIdx }}</div>
                <div :class="[ item.examDoneStr === '未检查' ? 'yellow' : 'green' ]">{{ item.examDoneStr }}</div>
            </div>
        </div>
    </div>
</body>
<script src="./common/cube.min.js"></script>
<script>
var vm = new Vue({
    el: '.wrapper',
    data: {
        host: 'http://132.147.200.96:8080',
        list: [],
        patientId: '',
        show: false,
        timer: undefined
    },
    created: function () {
        this.patientId = this.getUrlParams('userId')
        this.getData()
    },
    methods: {
        handleRefresh: function () {
            this.getData()
        },
        /**
         * 获取地址栏信息
         */
        getUrlParams: function (name) {
            var href = location.href.split('?')[1]
            var params = href.split('&')
            for (var i = 0; i < params.length; i++) {
                var key = params[i].split('=')[0]
                var val = params[i].split('=')[1]
                if (name == key) return val
            }
            return null
        },
        /**
         * 获取数据
         */
        getData: function () {
            var that = this
            that.show = false
            axios.post(this.host + '/followup/queuing/xcx?patient_id=' + this.patientId)
                .then(function (res) {
                    that.list = res.data
                    that.show = true
                    that.intervalRefresh()
                })
        },
        intervalRefresh: function () {
            if (this.timer) clearTimeout(this.timer)
            this.timer = setTimeout(this.getData, 5000)
        }
    }
})

</script>
</html>